package cn.ecut.Servlet;

import cn.ecut.Dao.adminsearch;

import javax.servlet.ServletException;
import java.io.IOException;
import java.sql.SQLException;

public class Servlettest extends javax.servlet.http.HttpServlet  {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, ServletException {
  doGet(request,response);
    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, ServletException {
  String res=request.getParameter("cusname");
  show s=new show();
        try {
            String[] s1=s.search(res);
            if(s1!=null){
            for (int i=0;i<4;i++){
               request.setAttribute("name",s1[0]);
               request.setAttribute("tel",s1[1]);
                request.setAttribute("mail",s1[2]);
                request.setAttribute("psw",s1[3]);
                request.getRequestDispatcher("admin.jsp").forward(request,response);
            }
            }
            else{request.getRequestDispatcher("fail.jsp").forward(request,response);}
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }


       }
       public  class show extends adminsearch {
        public String[] search(String res) throws SQLException, ClassNotFoundException {
            return  super.search(res);
        }
       }
    }

